package com.data.modules.online.config.executor;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.data.common.system.query.MatchTypeEnum;
import com.data.common.system.query.QueryGenerator;
import com.data.common.system.query.QueryRuleEnum;
import com.data.common.system.util.BootDataAutorUtils;
import com.data.common.system.vo.SysPermissionDataRuleModel;
import com.data.common.util.DateUtils;
import com.data.common.util.SpringContextUtils;
import com.data.common.util.ConvertUtils;
import com.data.modules.online.cgform.entity.OnlCgformField;
import com.data.modules.online.cgform.service.IOnlCgformFieldService;
import com.data.modules.online.cgform.util.CgformUtil;
import com.data.modules.online.cgform.util.OnlFormShowType;
import com.data.modules.online.cgreport.common.CgReportConstant;
import com.data.modules.online.cgreport.util.CgReportSqlUtil;
import com.data.modules.online.config.datasourceConfig.OnlineFieldConfig;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ConditionHandler {

    private static final Logger f444b = LoggerFactory.getLogger(ConditionHandler.class);

    public String f445a;

    private String f446c;

    private String f447d;

    private String f448e;

    private boolean f449f;

    private List<OnlineFieldConfig> f450g;

    private List<String> f451h;

    private List<SysPermissionDataRuleModel> f452i;

    private Map<String, Object> f453j;

    private StringBuffer f454k;

    private StringBuffer f455l;

    private Map<String, Object> f456m;

    private String f457n;

    private boolean f458o;

    private String f459p;

    private int f460q;

    private boolean f461r;

    private String f462s;

    private Map<String, String> f463t;

    private Map<String, String> f464u;


    public boolean mo1324a(Object obj) {
        return obj instanceof ConditionHandler;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ConditionHandler)) {
            return false;
        }
        ConditionHandler bVar = (ConditionHandler) o;
        if (!bVar.mo1324a(this)) {
            return false;
        }
        if (mo1323a() != bVar.mo1323a()) {
            return false;
        }
        if (mo1326b() != bVar.mo1326b()) {
            return false;
        }
        if (getUsePage() != bVar.getUsePage()) {
            return false;
        }
        if (mo1328c() != bVar.mo1328c()) {
            return false;
        }
        String alias = getAlias();
        String alias2 = bVar.getAlias();
        if (alias != null ? !alias.equals(alias2) : alias2 != null) {
            return false;
        }
        String aliasNoPoint = getAliasNoPoint();
        String aliasNoPoint2 = bVar.getAliasNoPoint();
        if (aliasNoPoint != null ? !aliasNoPoint.equals(aliasNoPoint2) : aliasNoPoint2 != null) {
            return false;
        }
        String dataBaseType = getDataBaseType();
        String dataBaseType2 = bVar.getDataBaseType();
        if (dataBaseType != null ? !dataBaseType.equals(dataBaseType2) : dataBaseType2 != null) {
            return false;
        }
        List<OnlineFieldConfig> fieldList = getFieldList();
        List<OnlineFieldConfig> fieldList2 = bVar.getFieldList();
        if (fieldList != null ? !fieldList.equals(fieldList2) : fieldList2 != null) {
            return false;
        }
        List<String> needList = getNeedList();
        List<String> needList2 = bVar.getNeedList();
        if (needList != null ? !needList.equals(needList2) : needList2 != null) {
            return false;
        }
        List<SysPermissionDataRuleModel> authDatalist = getAuthDatalist();
        List<SysPermissionDataRuleModel> authDatalist2 = bVar.getAuthDatalist();
        if (authDatalist != null ? !authDatalist.equals(authDatalist2) : authDatalist2 != null) {
            return false;
        }
        Map<String, Object> reqParams = getReqParams();
        Map<String, Object> reqParams2 = bVar.getReqParams();
        if (reqParams != null ? !reqParams.equals(reqParams2) : reqParams2 != null) {
            return false;
        }
        StringBuffer sql = getSql();
        StringBuffer sql2 = bVar.getSql();
        if (sql != null ? !sql.equals(sql2) : sql2 != null) {
            return false;
        }
        StringBuffer superQuerySql = getSuperQuerySql();
        StringBuffer superQuerySql2 = bVar.getSuperQuerySql();
        if (superQuerySql != null ? !superQuerySql.equals(superQuerySql2) : superQuerySql2 != null) {
            return false;
        }
        Map<String, Object> sqlParams = getSqlParams();
        Map<String, Object> sqlParams2 = bVar.getSqlParams();
        if (sqlParams != null ? !sqlParams.equals(sqlParams2) : sqlParams2 != null) {
            return false;
        }
        String daoType = getDaoType();
        String daoType2 = bVar.getDaoType();
        if (daoType != null ? !daoType.equals(daoType2) : daoType2 != null) {
            return false;
        }
        String matchType = getMatchType();
        String matchType2 = bVar.getMatchType();
        if (matchType != null ? !matchType.equals(matchType2) : matchType2 != null) {
            return false;
        }
        String paramPrefix = getParamPrefix();
        String paramPrefix2 = bVar.getParamPrefix();
        if (paramPrefix != null ? !paramPrefix.equals(paramPrefix2) : paramPrefix2 != null) {
            return false;
        }
        Map<String, String> duplicateSqlNameRecord = getDuplicateSqlNameRecord();
        Map<String, String> duplicateSqlNameRecord2 = bVar.getDuplicateSqlNameRecord();
        if (duplicateSqlNameRecord != null ? !duplicateSqlNameRecord.equals(duplicateSqlNameRecord2) : duplicateSqlNameRecord2 != null) {
            return false;
        }
        Map<String, String> duplicateParamNameRecord = getDuplicateParamNameRecord();
        Map<String, String> duplicateParamNameRecord2 = bVar.getDuplicateParamNameRecord();
        if (duplicateParamNameRecord != null ? !duplicateParamNameRecord.equals(duplicateParamNameRecord2) : duplicateParamNameRecord2 != null) {
            return false;
        }
        String subTableStr = getSubTableStr();
        String subTableStr2 = bVar.getSubTableStr();
        if (subTableStr == null) {
            if (subTableStr2 == null) {
                return true;
            }
        } else if (subTableStr.equals(subTableStr2)) {
            return true;
        }
        return false;
    }

    public int hashCode() {
        int i = 79;
        int i2 = 43;
        int usePage = ((((mo1326b() ? 79 : 97) + (((mo1323a() ? 79 : 97) + 59) * 59)) * 59) + getUsePage()) * 59;
        if (!mo1328c()) {
            i = 97;
        }
        int i3 = usePage + i;
        String alias = getAlias();
        int i4 = i3 * 59;
        int hashCode = alias == null ? 43 : alias.hashCode();
        String aliasNoPoint = getAliasNoPoint();
        int i5 = (hashCode + i4) * 59;
        int hashCode2 = aliasNoPoint == null ? 43 : aliasNoPoint.hashCode();
        String dataBaseType = getDataBaseType();
        int i6 = (hashCode2 + i5) * 59;
        int hashCode3 = dataBaseType == null ? 43 : dataBaseType.hashCode();
        List<OnlineFieldConfig> fieldList = getFieldList();
        int i7 = (hashCode3 + i6) * 59;
        int hashCode4 = fieldList == null ? 43 : fieldList.hashCode();
        List<String> needList = getNeedList();
        int i8 = (hashCode4 + i7) * 59;
        int hashCode5 = needList == null ? 43 : needList.hashCode();
        List<SysPermissionDataRuleModel> authDatalist = getAuthDatalist();
        int i9 = (hashCode5 + i8) * 59;
        int hashCode6 = authDatalist == null ? 43 : authDatalist.hashCode();
        Map<String, Object> reqParams = getReqParams();
        int i10 = (hashCode6 + i9) * 59;
        int hashCode7 = reqParams == null ? 43 : reqParams.hashCode();
        StringBuffer sql = getSql();
        int i11 = (hashCode7 + i10) * 59;
        int hashCode8 = sql == null ? 43 : sql.hashCode();
        StringBuffer superQuerySql = getSuperQuerySql();
        int i12 = (hashCode8 + i11) * 59;
        int hashCode9 = superQuerySql == null ? 43 : superQuerySql.hashCode();
        Map<String, Object> sqlParams = getSqlParams();
        int i13 = (hashCode9 + i12) * 59;
        int hashCode10 = sqlParams == null ? 43 : sqlParams.hashCode();
        String daoType = getDaoType();
        int i14 = (hashCode10 + i13) * 59;
        int hashCode11 = daoType == null ? 43 : daoType.hashCode();
        String matchType = getMatchType();
        int i15 = (hashCode11 + i14) * 59;
        int hashCode12 = matchType == null ? 43 : matchType.hashCode();
        String paramPrefix = getParamPrefix();
        int i16 = (hashCode12 + i15) * 59;
        int hashCode13 = paramPrefix == null ? 43 : paramPrefix.hashCode();
        Map<String, String> duplicateSqlNameRecord = getDuplicateSqlNameRecord();
        int i17 = (hashCode13 + i16) * 59;
        int hashCode14 = duplicateSqlNameRecord == null ? 43 : duplicateSqlNameRecord.hashCode();
        Map<String, String> duplicateParamNameRecord = getDuplicateParamNameRecord();
        int i18 = (hashCode14 + i17) * 59;
        int hashCode15 = duplicateParamNameRecord == null ? 43 : duplicateParamNameRecord.hashCode();
        String subTableStr = getSubTableStr();
        int i19 = (hashCode15 + i18) * 59;
        if (subTableStr != null) {
            i2 = subTableStr.hashCode();
        }
        return i19 + i2;
    }

    public void setAlias(String alias) {
        this.f446c = alias;
    }

    public void setAliasNoPoint(String aliasNoPoint) {
        this.f447d = aliasNoPoint;
    }

    public void setAuthDatalist(List<SysPermissionDataRuleModel> authDatalist) {
        this.f452i = authDatalist;
    }

    public void setDaoType(String daoType) {
        this.f457n = daoType;
    }

    public void setDataBaseType(String dataBaseType) {
        this.f448e = dataBaseType;
    }

    public void setDateStringSearch(boolean dateStringSearch) {
        this.f449f = dateStringSearch;
    }

    public void setDuplicateParamNameRecord(Map<String, String> duplicateParamNameRecord) {
        this.f464u = duplicateParamNameRecord;
    }

    public void setDuplicateSqlNameRecord(Map<String, String> duplicateSqlNameRecord) {
        this.f463t = duplicateSqlNameRecord;
    }

    public void setFieldList(List<OnlineFieldConfig> fieldList) {
        this.f450g = fieldList;
    }

    public void setFirst(boolean first) {
        this.f461r = first;
    }

    public void setMatchType(String matchType) {
        this.f459p = matchType;
    }

    public void setNeedList(List<String> needList) {
        this.f451h = needList;
    }

    public void setParamPrefix(String paramPrefix) {
        this.f462s = paramPrefix;
    }

    public void setReqParams(Map<String, Object> reqParams) {
        this.f453j = reqParams;
    }

    public void setSql(StringBuffer sql) {
        this.f454k = sql;
    }

    public void setSqlParams(Map<String, Object> sqlParams) {
        this.f456m = sqlParams;
    }

    public void setSubTableStr(String subTableStr) {
        this.f445a = subTableStr;
    }

    public void setSuperQuery(boolean superQuery) {
        this.f458o = superQuery;
    }

    public void setSuperQuerySql(StringBuffer superQuerySql) {
        this.f455l = superQuerySql;
    }

    public void setUsePage(int usePage) {
        this.f460q = usePage;
    }

    public String toString() {
        return "ConditionHandler(alias=" + getAlias() + ", aliasNoPoint=" + getAliasNoPoint() + ", dataBaseType=" + getDataBaseType() + ", dateStringSearch=" + mo1323a() + ", fieldList=" + getFieldList() + ", needList=" + getNeedList() + ", authDatalist=" + getAuthDatalist() + ", reqParams=" + getReqParams() + ", sql=" + ((Object) getSql()) + ", superQuerySql=" + ((Object) getSuperQuerySql()) + ", sqlParams=" + getSqlParams() + ", daoType=" + getDaoType() + ", superQuery=" + mo1326b() + ", matchType=" + getMatchType() + ", usePage=" + getUsePage() + ", first=" + mo1328c() + ", paramPrefix=" + getParamPrefix() + ", duplicateSqlNameRecord=" + getDuplicateSqlNameRecord() + ", duplicateParamNameRecord=" + getDuplicateParamNameRecord() + ", subTableStr=" + getSubTableStr() + ")";
    }

    public String getAlias() {
        return this.f446c;
    }

    public String getAliasNoPoint() {
        return this.f447d;
    }

    public String getDataBaseType() {
        return this.f448e;
    }

    public boolean mo1323a() {
        return this.f449f;
    }

    public List<OnlineFieldConfig> getFieldList() {
        return this.f450g;
    }

    public List<String> getNeedList() {
        return this.f451h;
    }

    public List<SysPermissionDataRuleModel> getAuthDatalist() {
        return this.f452i;
    }

    public Map<String, Object> getReqParams() {
        return this.f453j;
    }

    public StringBuffer getSql() {
        return this.f454k;
    }

    public StringBuffer getSuperQuerySql() {
        return this.f455l;
    }

    public Map<String, Object> getSqlParams() {
        return this.f456m;
    }

    public String getDaoType() {
        return this.f457n;
    }

    public boolean mo1326b() {
        return this.f458o;
    }

    public String getMatchType() {
        return this.f459p;
    }

    public int getUsePage() {
        return this.f460q;
    }

    public boolean mo1328c() {
        return this.f461r;
    }

    public String getParamPrefix() {
        return this.f462s;
    }

    public Map<String, String> getDuplicateSqlNameRecord() {
        return this.f463t;
    }

    public Map<String, String> getDuplicateParamNameRecord() {
        return this.f464u;
    }

    public ConditionHandler() {
    }

    public ConditionHandler(String str, String str2) {
        this.f446c = str;
        this.f447d = str.replace(".", "");
        this.f448e = str2;
        this.f449f = m395e(str2);
        this.f454k = new StringBuffer();
        this.f456m = new HashMap();
        this.f452i = null;
        this.f451h = null;
        this.f459p = CgformUtil.f294e;
        this.f460q = 1;
        this.f461r = true;
        this.f462s = "";
        this.f463t = new HashMap();
        this.f464u = new HashMap();
    }

    public ConditionHandler(String str) {
        this(str, null);
        this.f460q = 2;
    }

    public ConditionHandler(String str, boolean z, String str2) {
        this(str, null);
        this.f458o = z;
        this.f459p = " " + str2 + " ";
        this.f460q = 2;
    }

    public String mo1320a(List<OnlineFieldConfig> list, Map<String, Object> map) {
        mo1327c(list, map);
        m391d();
        return this.f454k.toString();
    }

    public String mo1321a(List<OnlineFieldConfig> list, Map<String, Object> map, List<SysPermissionDataRuleModel> list2) {
        setAuthDatalist(list2);
        mo1327c(list, map);
        m387b(list);
        m381a(map);
        return this.f454k.toString();
    }

    public String mo1322a(List<OnlineFieldConfig> list, Map<String, Object> map, List<SysPermissionDataRuleModel> list2, String str) {
        setAuthDatalist(list2);
        this.f462s = str;
        mo1327c(list, map);
        m387b(list);
        return this.f454k.toString();
    }

    public String mo1325b(List<OnlineFieldConfig> list, Map<String, Object> map) {
        mo1327c(list, map);
        return this.f454k.toString();
    }

    public String mo1319a(List<OnlineFieldConfig> list) {
        if (this.f458o) {
            for (OnlineFieldConfig eVar : list) {
                String name = eVar.getName();
                String val = eVar.getVal();
                if (val != null) {
                    QueryRuleEnum byValue = QueryRuleEnum.getByValue(eVar.getRule());
                    if (byValue == null) {
                        byValue = QueryRuleEnum.EQ;
                    }
                    m378a(name, eVar.getType(), val, byValue);
                }
            }
        }
        return this.f454k.toString();
    }

    public void mo1327c(List<OnlineFieldConfig> list, Map<String, Object> map) {
        for (OnlineFieldConfig eVar : list) {
            String name = eVar.getName();
            String type = eVar.getType();
            if (this.f451h != null && this.f451h.contains(name)) {
                eVar.setIsSearch(1);
                eVar.setMode(CgformUtil.f232F);
            }
            if (ConvertUtils.isNotEmpty(eVar.getMainField()) && ConvertUtils.isNotEmpty(eVar.getMainTable())) {
                eVar.setIsSearch(1);
                eVar.setMode(CgformUtil.f232F);
            }
            if (1 == eVar.getIsSearch().intValue()) {
                if ("group".equals(eVar.getMode())) {
                    String str = name + "_begin";
                    Object obj = map.get(this.f462s + str);
                    if (obj != null) {
                        m384b(name, CgReportConstant.f375v);
                        m385b(str, type, obj);
                    }
                    String str2 = name + "_end";
                    Object obj2 = map.get(this.f462s + str2);
                    if (obj2 != null) {
                        m384b(name, CgReportConstant.f376w);
                        m385b(str2, type, obj2);
                    }
                } else {
                    Object obj3 = map.get(this.f462s + name);
                    if (obj3 != null) {
                        String view = eVar.getView();
                        if ("list_multi".equals(view)) {
                            m394e(name, obj3);
                        } else if (CgformUtil.f239M.equals(view)) {
                            m397f(name, obj3);
                        } else {
                            m377a(name, type, obj3);
                        }
                    }
                }
            }
        }
    }

    public void setAuthList(List<SysPermissionDataRuleModel> authDatalist) {
        this.f452i = authDatalist;
    }

    private void m391d() {
        SysPermissionDataRuleModel sysPermissionDataRuleModel;
        List loadDataSearchConditon = BootDataAutorUtils.loadDataSearchConditon();
        if (loadDataSearchConditon != null && loadDataSearchConditon.size() > 0) {
            int i = 0;
            while (i < loadDataSearchConditon.size() && (sysPermissionDataRuleModel = (SysPermissionDataRuleModel) loadDataSearchConditon.get(i)) != null) {
                String ruleValue = sysPermissionDataRuleModel.getRuleValue();
                if (!ConvertUtils.isEmpty(ruleValue)) {
                    if (QueryRuleEnum.SQL_RULES.getValue().equals(sysPermissionDataRuleModel.getRuleConditions())) {
                        m384b("", QueryGenerator.getSqlRuleValue(ruleValue));
                    } else {
                        QueryRuleEnum byValue = QueryRuleEnum.getByValue(sysPermissionDataRuleModel.getRuleConditions());
                        String str = "Integer";
                        String trim = ruleValue.trim();
                        if (trim.startsWith(CgformUtil.f229C) && trim.endsWith(CgformUtil.f229C)) {
                            str = DataBaseConst.f474i;
                            trim = trim.substring(1, trim.length() - 1);
                        }
                        m378a(sysPermissionDataRuleModel.getRuleColumn(), str, QueryGenerator.converRuleValue(trim), byValue);
                    }
                }
                i++;
            }
        }
    }

    private OnlineFieldConfig m373a(String str, List<OnlineFieldConfig> list) {
        if (!(list == null || str == null)) {
            String camelToUnderline = ConvertUtils.camelToUnderline(str);
            for (int i = 0; i < list.size(); i++) {
                OnlineFieldConfig eVar = list.get(i);
                String name = eVar.getName();
                if (str.equals(name) || camelToUnderline.equals(name)) {
                    return eVar;
                }
            }
        }
        return null;
    }

    private void m387b(List<OnlineFieldConfig> list) {
        List<SysPermissionDataRuleModel> list2;
        SysPermissionDataRuleModel sysPermissionDataRuleModel;
        List<SysPermissionDataRuleModel> list3 = this.f452i;
        if (list3 == null) {
            list2 = BootDataAutorUtils.loadDataSearchConditon();
        } else {
            list2 = list3;
        }
        if (list2 != null && list2.size() > 0) {
            int i = 0;
            while (i < list2.size() && (sysPermissionDataRuleModel = list2.get(i)) != null) {
                String ruleValue = sysPermissionDataRuleModel.getRuleValue();
                if (!ConvertUtils.isEmpty(ruleValue)) {
                    if (QueryRuleEnum.SQL_RULES.getValue().equals(sysPermissionDataRuleModel.getRuleConditions())) {
                        m384b("", QueryGenerator.getSqlRuleValue(ruleValue));
                    } else {
                        OnlineFieldConfig a = m373a(sysPermissionDataRuleModel.getRuleColumn(), list);
                        if (a != null) {
                            m378a(a.getName(), a.getType(), QueryGenerator.converRuleValue(ruleValue), QueryRuleEnum.getByValue(sysPermissionDataRuleModel.getRuleConditions()));
                        }
                    }
                }
                i++;
            }
        }
    }

    private void m377a(String str, String str2, Object obj) {
        m378a(str, str2, obj, (QueryRuleEnum) null);
    }

    private void m378a(String str, String str2, Object obj, QueryRuleEnum queryRuleEnum) {
        if (obj != null) {
            String obj2 = obj.toString();
            boolean z = false;
            if (queryRuleEnum == null) {
                queryRuleEnum = QueryGenerator.convert2Rule(obj);
                z = true;
            }
            if (z) {
                obj2 = obj2.trim();
            }
            switch (C00071.f465a[queryRuleEnum.ordinal()]) {
                case 1:
                case 2:
                    m384b(str, queryRuleEnum.getValue());
                    if (z) {
                        obj2 = obj2.substring(1);
                    }
                    m385b(str, str2, (Object) obj2);
                    return;
                case 3:
                case 4:
                    m384b(str, queryRuleEnum.getValue());
                    if (z) {
                        obj2 = obj2.substring(2);
                    }
                    m385b(str, str2, (Object) obj2);
                    return;
                case 5:
                    m384b(str, queryRuleEnum.getValue());
                    m385b(str, str2, (Object) obj2);
                    return;
                case 6:
                    m384b(str, queryRuleEnum.getValue());
                    if (z) {
                        obj2 = obj2.replaceAll("\\+\\+", CgformUtil.f231E);
                    }
                    m385b(str, str2, (Object) obj2);
                    return;
                case 7:
                    m384b(str, " <> ");
                    if (z) {
                        obj2 = obj2.substring(1);
                    }
                    m385b(str, str2, (Object) obj2);
                    return;
                case 8:
                    m384b(str, " in ");
                    m379a(str, str2, obj2);
                    return;
                case 9:
                case 10:
                case 11:
                    m384b(str, CgformUtil.f295f);
                    if (z) {
                        m376a(str, obj2);
                        return;
                    } else {
                        m380a(str, obj2, queryRuleEnum);
                        return;
                    }
                default:
                    m384b(str, CgReportConstant.f374u);
                    m385b(str, str2, (Object) obj2);
                    return;
            }
        }
    }


    /* compiled from: ConditionHandler */
    public static /* synthetic */ class C00071 {

        static final /* synthetic */ int[] f465a = new int[QueryRuleEnum.values().length];

        static {
            try {
                f465a[QueryRuleEnum.GT.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                f465a[QueryRuleEnum.LT.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                f465a[QueryRuleEnum.GE.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                f465a[QueryRuleEnum.LE.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
            try {
                f465a[QueryRuleEnum.EQ.ordinal()] = 5;
            } catch (NoSuchFieldError e5) {
            }
            try {
                f465a[QueryRuleEnum.EQ_WITH_ADD.ordinal()] = 6;
            } catch (NoSuchFieldError e6) {
            }
            try {
                f465a[QueryRuleEnum.NE.ordinal()] = 7;
            } catch (NoSuchFieldError e7) {
            }
            try {
                f465a[QueryRuleEnum.IN.ordinal()] = 8;
            } catch (NoSuchFieldError e8) {
            }
            try {
                f465a[QueryRuleEnum.LIKE.ordinal()] = 9;
            } catch (NoSuchFieldError e9) {
            }
            try {
                f465a[QueryRuleEnum.RIGHT_LIKE.ordinal()] = 10;
            } catch (NoSuchFieldError e10) {
            }
            try {
                f465a[QueryRuleEnum.LEFT_LIKE.ordinal()] = 11;
            } catch (NoSuchFieldError e11) {
            }
        }
    }

    private void m379a(String str, String str2, String str3) {
        String[] split = str3.split(CgformUtil.f231E);
        if (split.length == 0) {
            m374a("('')");
            return;
        }
        String str4 = "";
        for (int i = 0; i < split.length; i++) {
            String trim = split[i].trim();
            String format = String.format("foreach_%s_%s", str, Integer.valueOf(i));
            if (i > 0) {
                str4 = str4 + CgformUtil.f231E;
            }
            String f = m396f(format);
            str4 = "jdbcTemplate".equals(this.f457n) ? str4 + ":" + f : str4 + "#{" + m382b(f) + "}";
            if ("Long".equals(str2) || "Integer".equals(str2)) {
                m375a(format, Integer.valueOf(Integer.parseInt(trim)));
            } else {
                m375a(format, (Object) trim);
            }
        }
        m374a("(" + str4 + ")");
    }

    private void m376a(String str, String str2) {
        String str3;
        m374a(m389c(str, "VARCHAR"));
        if ((str2.startsWith("*") && str2.endsWith("*")) || (str2.startsWith("%") && str2.endsWith("%"))) {
            str3 = "%" + str2.substring(1, str2.length() - 1) + "%";
        } else if (str2.startsWith("*") || str2.startsWith("%")) {
            str3 = "%" + str2.substring(1);
        } else if (str2.endsWith("*") || str2.endsWith("%")) {
            str3 = str2.substring(0, str2.length() - 1) + "%";
        } else {
            str3 = "%" + str2 + "%";
        }
        m375a(str, (Object) str3);
    }

    private void m380a(String str, String str2, QueryRuleEnum queryRuleEnum) {
        m374a(m389c(str, "VARCHAR"));
        if (queryRuleEnum == QueryRuleEnum.LEFT_LIKE) {
            m375a(str, (Object) ("%" + str2));
        } else if (queryRuleEnum == QueryRuleEnum.RIGHT_LIKE) {
            m375a(str, (Object) (str2 + "%"));
        } else {
            m375a(str, (Object) ("%" + str2 + "%"));
        }
    }

    private void m385b(String str, String str2, Object obj) {
        String lowerCase = str2.toLowerCase();
        if (m393d(str2)) {
            if (CgformUtil.m288g(obj.toString())) {
                m374a(obj.toString());
            } else {
                m374a("''");
            }
        } else if ("datetime".equals(lowerCase)) {
            m383b(str, DateUtils.str2Date(obj.toString(), (SimpleDateFormat) DateUtils.datetimeFormat.get()));
        } else if (OnlFormShowType.f320d.equals(lowerCase)) {
            m390c(str, DateUtils.str2Date(obj.toString(), (SimpleDateFormat) DateUtils.date_sdf.get()));
        } else {
            String trim = obj.toString().trim();
            if (!trim.startsWith(CgformUtil.f229C) || !trim.endsWith(CgformUtil.f229C) || this.f460q != 1) {
                m392d(str, trim);
            } else {
                m374a(trim);
            }
        }
    }

    private void m384b(String str, String str2) {
        m386b(str, str2, this.f459p);
    }

    private void m386b(String str, String str2, String str3) {
        if (this.f461r) {
            this.f461r = false;
        } else {
            this.f454k.append(str3);
        }
        if (str.length() > 0) {
            this.f454k.append(this.f446c).append(str).append(str2);
        } else {
            this.f454k.append(" ").append(str2).append(" ");
        }
    }

    private void m374a(String str) {
        this.f454k.append(str);
    }

    private String m389c(String str, String str2) {
        String f = m396f(str);
        if ("jdbcTemplate".equals(this.f457n)) {
            return ":" + f;
        }
        String b = m382b(f);
        if (str2 == null) {
            return String.format("#{%s}", b);
        }
        return String.format("#{%s, jdbcType=%s}", b, str2);
    }

    private String m382b(String str) {
        return "param." + m388c(str);
    }

    private void m375a(String str, Object obj) {
        this.f456m.put(m388c(m398g(str)), obj);
    }

    private String m388c(String str) {
        return this.f460q == 1 ? str : this.f447d + "_" + str;
    }

    private void m383b(String str, Object obj) {
        if (obj != null) {
            m374a(m389c(str, "TIMESTAMP"));
            m375a(str, obj);
        }
    }

    private void m390c(String str, Object obj) {
        if (obj != null) {
            m374a(m389c(str, "DATE"));
            m375a(str, obj);
        }
    }

    private void m392d(String str, Object obj) {
        if (obj != null) {
            m374a(m389c(str, (String) null));
            m375a(str, obj);
        }
    }

    private boolean m393d(String str) {
        return "Long".equals(str) || "Integer".equals(str) || "int".equals(str) || "double".equals(str) || "BigDecimal".equals(str);
    }

    private boolean m395e(String str) {
        return !"ORACLE".equals(str);
    }

    public static String m370a(String str, long j) {
        return str.replaceFirst("\\?", String.valueOf(j));
    }

    public static String m371a(String str, long j, long j2) {
        return str.replaceFirst("\\?", String.valueOf(j)).replaceFirst("\\?", String.valueOf(j2));
    }

    private void m394e(String str, Object obj) {
        if (obj != null) {
            String[] split = obj.toString().split(CgformUtil.f231E);
            String str2 = "";
            String str3 = this.f446c + str;
            int i = 0;
            while (i < split.length) {
                String str4 = str3 + " like '%" + split[i] + ",%' or " + str3 + " like '%," + split[i] + "%' or " + str3 + " = '" + split[i] + CgformUtil.f229C;
                if (str2.length() != 0) {
                    str4 = str2 + " or " + str4;
                }
                i++;
                str2 = str4;
            }
            if (str2.length() > 0) {
                m384b("", "(" + str2 + ")");
            }
        }
    }

    private void m397f(String str, Object obj) {
        if (obj != null) {
            String str2 = this.f446c + str;
            String str3 = "";
            String[] split = obj.toString().split(CgformUtil.f231E);
            for (int i = 0; i < split.length; i++) {
                String format = String.format("popup_%s_%s", str, Integer.valueOf(i));
                String c = m389c(format, "VARCHAR");
                m375a(format, (Object) ("%" + split[i] + "%"));
                str3 = str2 + CgformUtil.f295f + c;
                if (str3.length() != 0) {
                    str3 = str3 + CgReportSqlUtil.f391b + str3;
                }
            }
            if (str3.length() > 0) {
                m384b("", "(" + str3 + ")");
            }
        }
    }

    public String getSubTableStr() {
        return this.f445a;
    }

    private void m381a(Map<String, Object> map) {
        MatchTypeEnum matchTypeEnum;
        MatchTypeEnum byValue = MatchTypeEnum.getByValue(map.get("superQueryMatchType"));
        if (byValue == null) {
            matchTypeEnum = MatchTypeEnum.AND;
        } else {
            matchTypeEnum = byValue;
        }
        Object obj = map.get("superQueryParams");
        if (obj != null && !StringUtils.isBlank(obj.toString())) {
            try {
                JSONArray parseArray = JSONArray.parseArray(URLDecoder.decode(obj.toString(), "UTF-8"));
                IOnlCgformFieldService iOnlCgformFieldService = (IOnlCgformFieldService) SpringContextUtils.getBean(IOnlCgformFieldService.class);
                ArrayList arrayList = new ArrayList();
                arrayList.add("JEECG_SUPER_QUERY_MAIN_TABLE");
                if (this.f445a != null && !"".equals(this.f445a)) {
                    for (String str : this.f445a.split(CgformUtil.f231E)) {
                        arrayList.add(str);
                    }
                }
                HashMap hashMap = new HashMap();
                StringBuffer stringBuffer = new StringBuffer();
                for (int i = 0; i < arrayList.size(); i++) {
                    String str2 = (String) arrayList.get(i);
                    ArrayList arrayList2 = new ArrayList();
                    for (int i2 = 0; i2 < parseArray.size(); i2++) {
                        JSONObject jSONObject = parseArray.getJSONObject(i2);
                        String string = jSONObject.getString("field");
                        if (!ConvertUtils.isEmpty(string)) {
                            String[] split = string.split(CgformUtil.f231E);
                            OnlineFieldConfig eVar = new OnlineFieldConfig(jSONObject);
                            if ("JEECG_SUPER_QUERY_MAIN_TABLE".equals(str2) && split.length == 1) {
                                arrayList2.add(eVar);
                            } else if (split.length == 2 && split[0].equals(str2)) {
                                arrayList2.add(eVar);
                                if (((JSONObject) hashMap.get(str2)) == null) {
                                    List<OnlCgformField> queryFormFieldsByTableName = iOnlCgformFieldService.queryFormFieldsByTableName(str2);
                                    JSONObject jSONObject2 = new JSONObject();
                                    for (OnlCgformField onlCgformField : queryFormFieldsByTableName) {
                                        if (StringUtils.isNotBlank(onlCgformField.getMainTable())) {
                                            jSONObject2.put("subTableName", str2);
                                            jSONObject2.put("subField", onlCgformField.getDbFieldName());
                                            jSONObject2.put("mainTable", onlCgformField.getMainTable());
                                            jSONObject2.put("mainField", onlCgformField.getMainField());
                                        }
                                    }
                                    hashMap.put(str2, jSONObject2);
                                }
                            }
                        }
                    }
                    if (arrayList2.size() > 0) {
                        ConditionHandler bVar = new ConditionHandler(i == 0 ? this.f446c : this.f447d + i + ".", true, matchTypeEnum.getValue());
                        bVar.setDuplicateParamNameRecord(getDuplicateParamNameRecord());
                        bVar.setDuplicateSqlNameRecord(getDuplicateSqlNameRecord());
                        String a = bVar.mo1319a((List<OnlineFieldConfig>) arrayList2);
                        Map<String, Object> sqlParams = bVar.getSqlParams();
                        if (a != null && a.length() > 0) {
                            if (i == 0) {
                                stringBuffer.append(" ").append(a).append(" ");
                                this.f456m.putAll(sqlParams);
                            } else {
                                JSONObject jSONObject3 = (JSONObject) hashMap.get(str2);
                                String format = String.format(" %s in (select %s from %s %s where ", jSONObject3.getString("mainField"), jSONObject3.getString("subField"), jSONObject3.getString("subTableName"), this.f447d + i);
                                this.f456m.putAll(sqlParams);
                                stringBuffer.append(matchTypeEnum.getValue()).append(format).append(a).append(") ");
                            }
                        }
                    }
                }
                String stringBuffer2 = stringBuffer.toString();
                if (stringBuffer2.length() > 0) {
                    if (stringBuffer2.startsWith("AND ")) {
                        stringBuffer2 = stringBuffer2.substring(3);
                    } else if (stringBuffer2.startsWith("OR ")) {
                        stringBuffer2 = stringBuffer2.substring(2);
                    }
                    m384b("", "(" + stringBuffer2 + ")");
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    }

    private String m396f(String str) {
        return m372a(str, this.f463t);
    }

    private String m398g(String str) {
        return m372a(str, this.f464u);
    }

    private String m372a(String str, Map<String, String> map) {
        String str2 = map.get(str);
        if (str2 == null) {
            map.put(str, str + "_1");
            return str;
        }
        map.put(str, str + "_" + (Integer.parseInt(str2.substring(str2.lastIndexOf("_") + 1)) + 1));
        return str2;
    }
}
